home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / basic1 / pro11 / vgabox.bas < prev    next >
BASIC Source File  |  1990-11-22  |  5KB  |  110 lines

  1. ' =======================================================
  2. '  VGABOX.BAS  Copyright (c) 1990  Michael Welch
  3. '  included with GrafWiz by permission
  4. ' =======================================================
  5. '  Name:  VGABOX.BAS
  6. '  Type:  Main Module
  7. '  Lang:  Microsoft QuickBASIC v4.5
  8. '  Ver:   1.00
  9. '  Date:  10/30/1990
  10. '  By:    Michael Welch of Dallas, Texas
  11. '  Reqs:  Crescent Software's PDQ.LIB
  12. '         Tom Hanlin's Graphics Wizard replacement lib
  13. '  Purp:  (multifaceted):
  14. '         1.  To demonstrate the efficiency of Crescent's
  15. '             BCOMxx replacement library for QuickBASIC.
  16. '         2.  To demonstrate the capabilities and the
  17. '             extensions of Tom Hanlin's Graphics Wizard
  18. '             replacement graphics library.
  19. '         3.  To demonstrate the color range of the VGA's
  20. '             high-color mode.
  21. '| Mods:  Thomas G. Hanlin III
  22. '|        My modifications were largely a matter of
  23. '|        reformatting the source to appear more like
  24. '|        the other GRAFWIZ sources, for consistency.
  25. '|        A few other trivial alterations were made.
  26. ' =======================================================
  27. '
  28. DECLARE FUNCTION BiosInkey% ()          ' PDQ replacement for ASC(INKEY$)
  29. DECLARE FUNCTION PDQRand% (Range%)      ' PDQ replacement for RND
  30. DECLARE SUB PDQRandomize (Seed%)        ' PDQ replacement for RANDOMIZE
  31.  
  32.    REM $INCLUDE: 'GRAFWIZ.BI'
  33.  
  34.    DEFINT A-Z                           ' does not need floating point math
  35.  
  36.    GetDisplay Adapter, Mono            ' check adapter type
  37.    IF Adapter < 6 THEN                 ' just end if less than VGA
  38.       PRINT "Sorry, you need a VGA for this demo!"
  39.       END
  40.    END IF
  41.  
  42.    DEF SEG = 0
  43.    z = PEEK(&H41C) + PEEK(&H41D) * 256
  44.    PDQRandomize z                      ' RANDOMIZE based on system timer
  45.  
  46.    PRINT
  47.    PRINT "VGABOX v1.00 ≡ (P) 1990 Mike Welch"
  48.    PRINT "VGA animation demo of 256 colors"
  49.    PRINT "[] Slows down    [] Larger box"        ' <-- won't be able to
  50.    PRINT "[] Speeds up     [] Smaller box"       ' <-- print these chars!
  51.    PRINT "ESC Terminates    Other key, CLS"
  52.    PRINT
  53.    PRINT "Any key continues"
  54.    DO: LOOP UNTIL LEN(INKEY$)
  55.  
  56.    G13Mode 1                            ' SCREEN 13 replacement
  57.  
  58.    ' Altered from S&B4EGA to work with
  59.    ' the new SCREEN 13 mode of GRAFWIZ
  60.    G13Cls                                  ' clear screen
  61.    BoxSiz = 10                             ' initial box size
  62.    Delay = 10                              ' initial delay rate
  63.    DO                                      ' loop until keypress
  64.       EndLoop = 0                          ' reset Boolean flag
  65.       c = c + 1                            ' increase color counter
  66.       IF c > 246 THEN c = 1                ' reset if out of range (black)
  67.       DO                                   ' derive legal value for animation
  68.          X1 = X1 + Xo                      ' add to x-coord
  69.          Y1 = Y1 + Yo                      ' add to y-coord
  70.          z = PDQRand(2)                    ' used for animation, step value
  71.          IF X1 < 15 THEN                   ' if under x range
  72.             Xo = z                         ' enlarge value
  73.          ELSEIF X1 > 305 THEN              ' if over x range
  74.             Xo = 0 - z - 1                 ' decrease value
  75.          ELSEIF Y1 < 15 THEN               ' if under y range
  76.             Yo = z                         ' enlarge
  77.          ELSEIF Y1 > 185 THEN              ' if over y range
  78.             Yo = 0 - z - 1                 ' decrease
  79.          ELSE
  80.             EndLoop = -1                   ' quit computing and draw box
  81.          END IF
  82.       LOOP UNTIL EndLoop
  83.  
  84.       G13Color c, 0                        ' set color here
  85.       G13Box X1 - BoxSiz, Y1 + BoxSiz, X1 + BoxSiz, Y1 - BoxSiz, c
  86.  
  87.       IF c MOD Delay = 0 THEN CALL Pause(1)' delay 1/18th second
  88.  
  89.       a = BiosInkey                        ' no errors here w/PDQ
  90.       IF a THEN                            ' if a key was pressed
  91.          SELECT CASE a                     ' PDQ: -val for extended key
  92.             CASE -75                       ' left_arrow; slow down
  93.                IF Delay > 1 THEN Delay = Delay - 1
  94.             CASE -77                       ' right_arrow; speed up
  95.                IF Delay < 64 THEN Delay = Delay + 1
  96.             CASE -72                       ' up_arrow; make box larger
  97.                IF BoxSiz < 10 THEN BoxSiz = BoxSiz + 1
  98.             CASE -80                       ' down_arrow; make box smaller
  99.                IF BoxSiz > 2 THEN BoxSiz = BoxSiz - 1
  100.             CASE 27                        ' ESC
  101.                c = 0                       ' set end loop flag
  102.             CASE ELSE                      ' any other key
  103.               G13Cls                       ' clear screen
  104.          END SELECT
  105.       END IF
  106.    LOOP WHILE c
  107.  
  108.    G13Mode 0                               ' restore text mode
  109.    PRINT "";
  110.